import request from "@/utils/request";
import { API_BASE_URL, WS_URL } from '@/constants'

export function getNetworkInfo() {
  return request(API_BASE_URL + 'blockchain/nodeBrowse/', {
    method: 'GET'
  });
}

export function getNodeInfo() {
  return request(API_BASE_URL + 'node/nodeInfo/', {
    method: 'GET'
  });
}

export function listenSocket(cb) {
  const socket = new WebSocket("ws://" + WS_URL);
  socket.addEventListener('message', function (event) {
    cb(JSON.parse(event.data));
  });
  return socket;
}
